package org.gongliang.jsmile.authc.sys.controller;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.gongliang.jsmile.authc.sys.entity.SysLog;
import org.gongliang.jsmile.authc.sys.service.SysLogService;
import org.gongliang.jsmile.common.base.BaseController;
import org.gongliang.jsmile.common.base.JSmileResult;
import org.gongliang.jsmile.common.kit.web.WebKit;
import org.gongliang.jsmile.config.log.info.KLog;
import org.gongliang.jsmile.config.log.info.LogType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.github.pagehelper.PageInfo;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
* @desc   控制器
* @author 龚亮
* @version 1.0
* @date 2018年08月25日 04:57:24
*/
@Controller
@RequestMapping("/sys_log")
@Api(tags = "日志管理")
public class SysLogController extends BaseController {

    @Autowired
    private SysLogService sysLogService;
    
	@GetMapping("/main")
	public String main() {
		return "sys/Log/log";
	}

	/**
	 * 查询所有分页 返回 Lit<Map>
	 */
	@ResponseBody
	@ApiOperation(value = "日志记录列表")
	@RequestMapping("/findAllByPage")
	@KLog(title = "日志管理->分页获取日志列表", type = LogType.QUERY)
	public JSmileResult findAllMapByPage(HttpServletRequest request) {
		Map<String, Object> reqMap = WebKit.getParams(request);
		WebKit.setPage(WebKit.toPageIndex(reqMap), WebKit.toPageSize(reqMap));
		List<SysLog> list = sysLogService.findAll(reqMap);
		PageInfo<SysLog> pages = new PageInfo<SysLog>(list);
		JSmileResult result = JSmileResult.success();
		result.setResData(pages.getList(), pages.getTotal());
		return result;
	}


}
